<?php

class photo_ctrl extends Controller
{


    //////每一个都进行单个提交

    public function __construct()
    {
        parent::__construct();

    }

    //获取视频
    public function up_photo()
    {
        if (!$this->ajax_err) {
            $photo = $_REQUEST["photo"];
            //$photo = '';

            /*$image = file_get_contents(BASE_PATH.'/photo/1.jpg');
            file_put_contents(BASE_PATH.'/photo/image.jpg', $image);*/

            $photo = str_replace('data:image/png;base64,','',$photo);
            $photo = str_replace(' ','+',$photo) ;
            //Base64解码
            $photo = base64_decode($photo);

            $_mdl = Loader::top('wantu');
            $data = $_mdl->upload_file($photo);
            $photo_url = preg_replace("/(.*?:)(.*)/","$2", $data['url']).'?t='.time();
            return $this->ajax( $photo_url);
        } else {
            return $this->ajax('', array(1, '未登录', 1, '请登录'));
        }
    }


}